<?php

include_once ('bn_path.php');

class bn_config
{

    private $dl;
    protected static $instance;

    public function __construct()
    {
        $this->dl = new bn_dal();
    }

    public static function getInstance()
    {
        if (!isset(self::$instance))
        {
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function delete_conf($name)
    {
        $this->dl->delete('config', $name, 'name');
    }

    public function Get_value($name)
    {
        return $this->dl->getvalue('select value from config where name=?',$name);
    }

    public function Set_value($name, $val)
    {
        if (self::has_conf($name) == '')
            $this->dl->insert('config', func_get_args());
        else
            $this->dl->update('config', array('value' => $val), array('name=' => $name));
    }

    public function has_conf($name)
    {
        return $this->dl->hasrow('select value from config where name=?', func_get_args
            ());
    }

    public function get_header()
    {
        return self::Get_value('header');
    }

    public function get_footer()
    {
        return self::Get_value('footer');
    }

    public function get_default_lang()
    {
        return self::Get_value('default_language');
    }

    public function __destruct()
    {
        unset($this->dl);
    }
}

?>